#!/usr/bin/env python
#coding:utf-8
import web
import cgi
import pymongo
import feedparser
from utils import render



urls = (
"", "index",
"/feedparse", "feedparse",  
"/make","bookmake",
)

class index:
    def GET(self):
        session = web.ctx.session
        return render.book(session=session)

class feedparse:
    def POST(self):
        session = web.ctx.session
        feedurl = web.input().get('feedurl')
        if not feedurl:
            raise web.seeother('/book',absolute=True) 
        else:
            result= feedparser.parse(feedurl)
            items = result['entries']


            print result
            return render.book(session=session,result=result)   

class bookmake:
    def POST(self):
         session = web.ctx.session
         ids_tmp = web.input(rsscgp=[]).get('rsscgp')
         ids = [int(ix) for ix in ids_tmp ]


app_book = web.application(urls, locals())
